﻿package net.wangit.view.chart.impl;

import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.AreaRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.urls.StandardCategoryURLGenerator;
import org.jfree.data.category.CategoryDataset;

public class AreaChart extends CategoryChart {

	public AreaChart() {
	}

	protected CategoryPlot getCategoryPlot() {
		CategoryDataset dataset = (CategoryDataset) getDataset();
		CategoryAxis categoryAxis = getCategoryAxis();
		categoryAxis.setCategoryMargin(0.0D);
		org.jfree.chart.axis.ValueAxis valueAxis = getNumberAxis();
		CategoryItemRenderer renderer = getRenderer();
		CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
				renderer);
		return plot;
	}

	private CategoryItemRenderer getRenderer() {
		AreaRenderer renderer = new AreaRenderer();
		if (tooltips)
			renderer
					.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
		if (urls)
			renderer
					.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
		configCategoryRenderer(renderer);
		return renderer;
	}
}
